<?php use Backend\Controller\Plugin\AuthorizationPlugin; ?>

<?php if( AuthorizationPlugin::isAllowed2($this->layout()->loadIdentity, "Agence", "create") ) { ?>
	<div class="row">
		<div class="col-lg-2">
			<a href="creation" class="form-control btn btn-primary" role="button">Ajouter</a>
		</div>
	</div>
	<br/>
<?php } ?>

<div ng-app="agenceModule">
	<div class="table-responsive" ng-controller="AgenceController">
		<table class="table table-bordered table-hover table-striped tablesorter">
	    	<thead>
	        	<tr>
					<th>Libell&#233; <i class="fa fa-sort"></i></th>
					<th>Ville <i class="fa fa-sort"></i></th>
					<th>&nbsp;</th>
				</tr>
			</thead>
			<tbody>
				<tr ng-repeat="agence in agences">
					<td>{{agence.libelle}}</td>
					<td>{{agence.ville}}</td>
					<td>
						<div class="btn-group">
							<button type="button" class="btn btn-primary">Actions</button>
						  	<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
						    	<span class="caret"></span>
						    	<span class="sr-only">Toggle Dropdown</span>
						  	</button>
						  	<ul class="dropdown-menu" role="menu">
						  		<?php if( AuthorizationPlugin::isAllowed2($this->layout()->loadIdentity, "Agence", "edit") ) { ?>
						    		<li><a href="/agence/edition?id={{agence.id}}">Editer</a></li>
						    	<?php } ?>
						    	<?php if( AuthorizationPlugin::isAllowed2($this->layout()->loadIdentity, "Agence", "delete") ) { ?>
						    		<li><a href="#" ng-click="deleteAgence(agence)">Supprimer</a></li>
						    	<?php } ?>
						  	</ul>
						</div>
					</td>
				</tr>
			</tbody>
		</table>
		<ng-modal ng-model="modal" bouton-valider="supprimerAgence()" />
	</div>
</div>	



